<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数据类型</title>

    <script>
        var a = 123
        var f = 2.3
        var str = "hello"
        var bo = true
        var un

        console.log(a   + ":" + typeof(a))
        console.log(f   + ":" + typeof(f))
        console.log(str + ":" + typeof(str))
        console.log(bo  + ":" + typeof(bo))
        console.log(un  + ":" + typeof(un))

        a = "hehe"
        console.log(a   + ":" + typeof(a))
        var str3 = new String("new字符串")

        console.log(str3 + ":" + typeof(str3) )

        //数组
        var arr = [1, "2", true, 3.14]
        console.log(arr   + ":" + typeof(arr))


        var arr2 = new Array("hello", 234, false)
        console.log(arr2   + ":" + typeof(arr2))
        var arr3 = new Array()
        // arr3[0] = "hello"
        arr3[1] = "world"

        arr3[2] = 33
        console.log(arr3   + ":" + typeof(arr3))
        console.log(arr[8])

        arr[9] = "第九个"
        console.log(arr   + ":" + typeof(arr))

        console.log("====================")
        // for (var i=0; i<length(arr); i++) {
        //     console.log(arr[i])
        // }

        console.log(arr.push(110))
        console.log(arr)


        //对象
        var person = {
            name:"huahua",
            age:20,
        }

        console.log(person)
        console.log(person   + ":" + typeof(person))

        //读写对象属性
        console.log(person.name)
        person.name= "heihei"
        console.log(person.name)
        //动态添加属性
        person.sex = "男"
        console.log(person.sex)
        console.log(person["age"])


    </script>

</head>
<body>

</body>
</html>